#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>
#include<unordered_set>

using namespace std;

int maximumNumberOfStringPairs(vector<string>& words) {
    int n = words.size();
    int res = 0;
    unordered_set<int> us;
    for (int i = 0; i < n; i++)
    {
        if (us.count(words[i][1] * 100 + words[i][0]))
            res++;
        us.insert(words[i][0] * 100 + words[i][1]);
    }
    return res;
}